package suse.hotel.admin.admin.Mapper;

import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;
import suse.hotel.admin.admin.DTO.AdminDTO;
import suse.hotel.admin.admin.DTO.UserDTO;
import suse.hotel.admin.admin.Entity.Admin;

import java.util.List;

@Repository
@Mapper
public interface AdminMapper {

    @Select("select * from admin where admin_name=#{adminName} and admin_password=#{adminPassword}")
    AdminDTO loginSelect(Admin admin);

    @Select("select * from user")
    List<UserDTO> selUser();

    @Select("select * from admin")
    List<AdminDTO> selAdmin();

    @Delete("delete from user where id=#{id}")
    int delMenber(int id);

    @Delete("delete from admin where admin_id=#{id}")
    int delAdmin(int id);

    @Insert("INSERT INTO admin (admin_name,admin_password) VALUES (#{username},#{password})")
    void addAdmin(String username,String password);

    @Update("UPDATE user SET username = #{username}, email = #{email},password=#{password} WHERE id = #{id}")
    int editUser(UserDTO userDTO);

    @Update("UPDATE admin SET admin_name = #{adminName},admin_password = #{adminPassword} WHERE admin_id = #{adminId}")
    int editAdmin(AdminDTO adminDTO);
}
